package com.company.biz.purchase.action;


import com.company.biz.purchase.service.OrderFormService;
import com.company.purchase.entity.PurchaseOrderEntity;
import com.company.purchase.req.*;
import com.company.user.vo.GeneralResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(description="采购订单管理")
@RestController
@RequestMapping("/OrderForm")
public class OrderFormController {

    @Resource
    private OrderFormService orderFormService;





    /**
     * 获取采购订单分页
     * */
    @ApiOperation("获取采购订单分页")
    @RequestMapping(value = "/getPurchaseListPages",method = RequestMethod.POST)
    public GeneralResult<List<PurchaseOrderEntity>> getPurchaseListPages(@RequestBody getPurchaseListPagesReq req){
        List<PurchaseOrderEntity> PurchaseOrderPageList = orderFormService.getPurchaseOrderListPages(req);
        return  GeneralResult.genSuccessResult(PurchaseOrderPageList);
    }

    /**
     * 根据采购id查询
     * */
    @ApiOperation("根据采购id查询")
    @RequestMapping(value = "/getPurchaseById",method = RequestMethod.POST)
    public GeneralResult<List<PurchaseOrderEntity>> getPurchaseById(@RequestBody getPurchasePagesByIdReq req){
        List<PurchaseOrderEntity> PurchaseOrderPage = orderFormService.getPurchaseById(req.getPurchaseId());
        return  GeneralResult.genSuccessResult(PurchaseOrderPage);
    }

    /**
     * 删除指定订单
     * */
    @ApiOperation("删除指定订单")
    @RequestMapping(value = "/PurchaseDeletById",  method = RequestMethod.POST)
    public GeneralResult PurchaseDeletById(@RequestBody PurchaseDeletByIdReq req){
       boolean flag =  orderFormService.PurchaseDeletById(req);
        return  GeneralResult.genSuccessResult(flag);
    }

    /**
     * 修改指定订单
     * */
    @ApiOperation("修改指定订单")
    @RequestMapping(value = "/PurchaseUpdateById",  method = RequestMethod.POST)
    public GeneralResult PurchaseUpdateById(@RequestBody PurchaseUpdateByIdReq req){
        orderFormService.PurchaseUpdateById(req);
        return GeneralResult.genSuccessResult();
    }

    /**
     * 批量添加订单
     * */
    @ApiOperation("批量添加订单")
    @RequestMapping(value = "/PurchaseAddById",  method = RequestMethod.POST)
    public GeneralResult PurchaseAddById(@RequestBody List<getPurchaseAddByIdReq> req){
        orderFormService.PurchaseAddById(req);
        return GeneralResult.genSuccessResult();
    }

}
